package br.edu.ufcg.ga.stopcondition;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class MaxBestFitnessRepetitionStopConditionTest {

	private MaxBestFitnessRepetitionStopCondition mbfrsc;

	@Before
	public void setUp() throws Exception {
		this.mbfrsc = new MaxBestFitnessRepetitionStopCondition(3);
	}

	@Test
	public void testReachedStopCondition() {

		int generation = 1;

		for (int i = 0; i < 1; i++) {
			assertFalse(this.mbfrsc.reached(generation++, 160.0));
		}
		
		for (int i = 0; i < 2; i++) {
			assertFalse(this.mbfrsc.reached(generation++, 155.0));
		}
		
		for (int i = 0; i < 3; i++) {
			assertFalse(this.mbfrsc.reached(generation++, 150.0));
		}
		assertTrue(this.mbfrsc.reached(generation++, 150.0));

	}

}
